package xm.control.bar
{
	import xm.control.bar.barContent.TabContent;
	import xm.control.bar.base.BarBase;
	import xm.definition.Align;
	
	/**
	 * <br> 클래스 설명 : </br>
	 * @author 김정환
	 */	
	public class TabBar extends BarBase
	{
		
		//-----------------------------------------------------------------------------------
		// public vars
		//-----------------------------------------------------------------------------------
		
		
		
		
		//-----------------------------------------------------------------------------------
		// protected / internal vars
		//-----------------------------------------------------------------------------------
		protected var tabContent : TabContent;
		
		
		
		//-----------------------------------------------------------------------------------
		// private vars
		//-----------------------------------------------------------------------------------
		
		
		
		
		//-----------------------------------------------------------------------------------
		// public functions
		//-----------------------------------------------------------------------------------
		
		/**
		 * constructor 
		 */	
		public function TabBar()
		{
			super();
			
			this.align = Align.BOTTOM;
		}
		
		/**
		 * @param content : ContentBase : TabContent
		 */		
		public function setTabContent( content : TabContent ):void
		{
			if( tabContent )
			{
				tabContent.remove();
			}
			
			tabContent = content;
			
			if( content != null )
			{
				content.apply( this );
				content.createChildren();
				content.add();
				
				this.invalidateDisplayList();
			}
			
			if( content == null && s.contains( this ) )
			{
				this.removeFromStage();
			}
			else if( content != null && s.contains( this ) == false )
			{
				this.addToStage();
			}
			
		}
		
		
		
		
		/**
		 *  updateDisplayList
		 */		
		override public function updateDisplayList( enforce : Boolean = false ):void
		{
			super.updateDisplayList(enforce);
			
			if( tabContent )
			{
				if( this.align == Align.BOTTOM )
				{
					this.y = s.stageHeight-paddingBottom-viewHeight;
				}
				
				tabContent.apply( this );
			}
		}
		
		
		
		/**
		 * destroy
		 */		
		override public function destroy():void
		{
			
			if( tabContent )
			{
				tabContent.destroy();
				tabContent = null;
			}
			
			super.destroy();
		}
		
		
		//-----------------------------------------------------------------------------------
		// setter / getter
		//-----------------------------------------------------------------------------------
		
		
		//-----------------------------------------------------------------------------------
		// protected functions
		//-----------------------------------------------------------------------------------
		
		
		//-----------------------------------------------------------------------------------
		// internal functions
		//-----------------------------------------------------------------------------------
		
		
		
		
		//-----------------------------------------------------------------------------------
		// private functions
		//-----------------------------------------------------------------------------------
		
		
		
		
		
		//-----------------------------------------------------------------------------------
		// event handler
		//-----------------------------------------------------------------------------------
		
		
		
		
	}
}







